package com.isdepci.project.factor.utils;

import com.isdepci.common.constant.Constants;
import com.isdepci.common.utils.StringUtils;
import com.isdepci.common.utils.spring.SpringUtils;
import com.isdepci.framework.redis.RedisCache;
import com.isdepci.project.factor.domain.CategorizeInfo;
import com.isdepci.project.factor.domain.EnterpriseInfo;
import com.isdepci.project.factor.domain.ProductCategorize;
import com.isdepci.project.factor.domain.StandardStage;

import java.util.Collection;
import java.util.List;

/**
 * @author Administrator
 */
public class FactorRedisUtils {

    public static final String CATEGORIZE_KEY = Constants.PROJECT_NAME+"categorize_dict";

    //--------------------------------------------------分类缓存
    public static void setCategorizeInfoCache(List<CategorizeInfo> list) {
        SpringUtils.getBean(RedisCache.class).setCacheObject(CATEGORIZE_KEY, list);
    }
    public static List<CategorizeInfo> getCategorizeInfoCache() {
        Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(CATEGORIZE_KEY);
        if (StringUtils.isNotNull(cacheObj)) {
            return StringUtils.cast(cacheObj);
        }
        return null;
    }
    public static void clearListCache() {
        SpringUtils.getBean(RedisCache.class).deleteObject(CATEGORIZE_KEY);
    }

    //------------------------------------------------标准流程缓存
    public static final String STANDARD_STAGE_KEY = Constants.PROJECT_NAME+"standard_stage_dict";

    public static void setStandardStageCache(List<StandardStage> list) {
        SpringUtils.getBean(RedisCache.class).setCacheObject(STANDARD_STAGE_KEY, list);
    }
    public static List<StandardStage> getStandardStageCache() {
        Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(STANDARD_STAGE_KEY);
        if (StringUtils.isNotNull(cacheObj)) {
            return StringUtils.cast(cacheObj);
        }
        return null;
    }
    public static void clearStandardStageCache() {
        SpringUtils.getBean(RedisCache.class).deleteObject(STANDARD_STAGE_KEY);
    }

    //--------------------------------------------------产品分类缓存
    public static final String PRODUCT_CATEGORIZE_KEY = Constants.PROJECT_NAME+"product_categorize_dict";
    public static void setProductCategorizeCache(List<ProductCategorize> list) {
        SpringUtils.getBean(RedisCache.class).setCacheObject(PRODUCT_CATEGORIZE_KEY, list);
    }
    public static List<ProductCategorize> getProductCategorizeCache() {
        Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(PRODUCT_CATEGORIZE_KEY);
        if (StringUtils.isNotNull(cacheObj)) {
            return StringUtils.cast(cacheObj);
        }
        return null;
    }
    public static void clearProductCategorizeListCache() {
        SpringUtils.getBean(RedisCache.class).deleteObject(PRODUCT_CATEGORIZE_KEY);
    }

    //--------------------------------------------------企业库
    public static final String ENTERPRISE_LIST_KEY = Constants.PROJECT_NAME+"enterprise_info_list";
    public static void setEnterpriseInfoListCache(List<EnterpriseInfo> list) {
        SpringUtils.getBean(RedisCache.class).setCacheObject(ENTERPRISE_LIST_KEY, list);
    }
    public static List<EnterpriseInfo> getEnterpriseInfoListCache() {
        Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(ENTERPRISE_LIST_KEY);
        if (StringUtils.isNotNull(cacheObj)) {
            return StringUtils.cast(cacheObj);
        }
        return null;
    }
    public static void clearEnterpriseInfoListCache() {
        SpringUtils.getBean(RedisCache.class).deleteObject(ENTERPRISE_LIST_KEY);
    }


}
